//
//  HMStatus.swift
//  WeiBo
//
//  Created by 李立达 on 15/12/10.
//  Copyright © 2015年 heima11. All rights reserved.
//

import UIKit

class HMStatus: NSObject {

    //原创微博内容
    var text : String?
    //用户信息
    var user : HMUser?
    //创建时间
    var created_at : String?
    //微博来源
    var source : String?
    //转发条数
    var repost_count : Int = 0
    //评论
    var comments_count : Int = 0
    //转发微博的内容
    var attitudes_count : Int = 0
    
    var id : Int64 = 0
    //转发微博的内容
    var retweeted_status : HMStatus?
    
    var pic_urls : [HMPictureInfo]?
    init(dict : [String : AnyObject]) {
        super.init()
        setValuesForKeysWithDictionary(dict)
    }
    
    override func setValue(value: AnyObject?, forKey key: String) {
        
        if(key == "user")
        {
            if let dictvalue = value as? [String:AnyObject]
            {
                user = HMUser(dict: dictvalue)
            }
        }else if(key == "retweeted_status")
        {
            if let dictvalue = value as? [String:AnyObject]
            {
                retweeted_status = HMStatus(dict: dictvalue)
            }
        }
        else if(key == "pic_urls")
        {
            if let dictvalue = value as? [[String:AnyObject]]
            {
                var tempArray = [HMPictureInfo]()
                
                for dict in dictvalue
                {
                   tempArray.append(HMPictureInfo(dict: dict))
                }
                pic_urls = tempArray
            }
        }
        else
        {
            super.setValue(value, forKey: key)
        }
    }
    override func setValue(value: AnyObject?, forUndefinedKey key: String) {
        

    }
    override var description: String {
        let keys = ["text"]
        return dictionaryWithValuesForKeys(keys).description
    }
}
